package com.sunsl.jobschedule.job;

import com.sunsl.jobschedule.entity.KbConsumptionRecord;
import com.sunsl.jobschedule.service.KbConsumptionRecordService;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class QueryAbnormalOrderPayResultJob implements BaseJob {

    private static Logger logger = LoggerFactory.getLogger(QueryAbnormalOrderPayResultJob.class);

    @Autowired
    private KbConsumptionRecordService kbConsumptionRecordService;

    public QueryAbnormalOrderPayResultJob() {

    }

    public void execute(JobExecutionContext jobContext) throws JobExecutionException {
        logger.info("QueryAbnormalOrderPayResultJob开始执行...");

        List<KbConsumptionRecord> list = kbConsumptionRecordService.getAbnormalConsumptionRecordList();
        if(list.size() > 0)
        {
            logger.info("QueryAbnormalOrderPayResultJob：查询到异常订单数为：" + list.size());
            //todo:
            for (KbConsumptionRecord record : list) {
                //对接业务平台核对交易结果是否正确

                if(true) {
                    //如果交易结果核对正确，如何处理？
                } else {
                    //交易结果核对不正确，更新记录表

                }
            }
        } else {
            logger.info("QueryAbnormalOrderPayResultJob：未查询到异常订单...");
        }

        logger.info("QueryAbnormalOrderPayResultJob执行完毕...");
    }
}
